<template>
  <div>
    <ymm-content title="体检管理">
      <template slot="toolbar">
        <exam-toolbar :data-type="dataType" @typeChange="onTypeChange"/>
      </template>
      <template>
        <exam-table :exams="exams" @showInfo="showInfo"/>
      </template>
    </ymm-content>
  </div>
</template>

<script>
import YmmContent from "@/components/common/ymm-content";
import ExamToolbar from "@/views/doctor/exam/exam-toolbar";
import ExamTable from "@/views/doctor/exam/exam-table";
import {getAllExamList} from "@/api/advice";

export default {
  data() {
    return {
      dataType: 0,
      pageSize: 10,
      pageNum: 1,
      name: '',
      exams: [],
      total: 0
    }
  },
  components: {
    YmmContent, ExamToolbar, ExamTable
  },
  methods: {
    /*index事件*/
    getExams() {
      getAllExamList(this.pageNum, this.pageSize, this.name, this.dataType).then(res => {
        this.exams = res.rows
        this.total = res.total
      }).catch(err => {
        this.$message.error('获取体检列表失败')
      })
    },
    /*ToolBar事件*/
    onTypeChange(val) {
      this.pageNum = 1
      this.dataType = val
      this.getExams()
    },
    /*table*/
    showInfo(exam) {
      this.$store.commit('student/CHANGE_EXAM', exam)
      this.$router.push({name: 'ExamDetail'})
    }
  },
  created() {
    this.getExams()
  }
}
</script>

<style scoped lang="less">

</style>
